﻿Imports TrigHelper

Public Class Form1
    Private polygon() As PointF = Geometry.GetPolygonPoints(48, 8, New PointF(100, 100))
    Private path As New Drawing2D.GraphicsPath

    Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
        Dim contains1, contains2 As Boolean
        Dim sw As New Stopwatch
        sw.Start()
        contains1 = Geometry.PolygonContains(New PointF(e.X, e.Y), polygon)
        sw.Stop()
        Dim t1 As Double = sw.Elapsed.TotalMilliseconds
        sw.Restart()
        contains2 = path.IsVisible(e.X, e.Y)
        sw.Stop()
        Dim t2 As Double = sw.Elapsed.TotalMilliseconds
        Me.Text = String.Format("Contains {0} in {1}, IsVisble {2} in {3}", contains1, t1, contains2, t2)

    End Sub

    Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
        e.Graphics.DrawPolygon(Pens.Blue, polygon)

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        path.AddPolygon(polygon)
        path.CloseFigure()
    End Sub
End Class
